﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace linkouqs.Gamekit {
    public class InventoryCharacter : MonoBehaviour
    {
      

        // Update is called once per frame
        void Update()
        {
            //G 随机得到一个物品放到背包里面
            if (Input.GetKeyDown(KeyCode.G))
            {
                int id = Random.Range(1, 2);
                Knaspack.Instance.StoreItem(id);
            }

            if(Input.GetKeyDown(KeyCode.I))
            {
                DisplaySwitch(UIPanelType.KnapsackPanel);
            }
          
            if(Input.GetKeyDown(KeyCode.O))
            {
                DisplaySwitch(UIPanelType.StorePanel);
               
            }
        }


        public void Show(UIPanelType panel)
        {
            UIManager.Instance.PushPanel(panel);
        
        }

        public void Hide()
        {
            UIManager.Instance.PopPanel();
            
        }

        public void DisplaySwitch(UIPanelType panel)
        {
            BasePanel bPanel = UIManager.Instance.GetPanel(panel);
            CanvasGroup canv = bPanel.gameObject.GetComponent<CanvasGroup>();

            if (canv.blocksRaycasts==false)
            {
                Show(panel);
            }
            else
            {
                Hide();
                
            }
        }
    }
}
